package com.rd.student.jike.class2.lihongming.Exam;

import java.io.*;
import java.util.HashMap;
import java.util.Scanner;

/**
 * @Auther:Heinrich
 * @Date:2023/8/8-08-08-16:00
 * @Description:com.rd.student.jike.class2.lihongming.Exam
 * @version:1.0
 */
public class Question2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        HashMap<String,String> players = playerMap();
        System.out.println("请输入球员姓名");
        String name = sc.next();
        System.out.println(players.getOrDefault(name, "不存在该球员"));
    }
    public static HashMap<String,String> playerMap(){
        HashMap<String,String> players = new HashMap<>();
        try(BufferedReader reader = new BufferedReader(new FileReader(new File("./src/com/rd/student/jike/class2/lihongming/Exam/player.txt")));){
            String str;
            while ((str = reader.readLine()) != null) {
                players.put(str.split("，")[0], str.split("，")[1]);
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        return players;
    }
}
